<?php
class Admin_operat extends CI_Controller {
	
	public function __construct() {
		parent::__construct ();
		$this->load->model ( 'operat_Mod', 'op' );
		$this->load->model ( 'operat_type_Mod', 'op_ty' );
		$this->load->library ( 'session' );
	}
	
	//查看
	public function index() {
		
		$this->view->assign ( "operat", $this->op->read_all () );
		
		$this->view->display ( "admin_operat" );
	}
	
	//管理员类别
	public function type() {
		$this->view->assign ( "type", $this->op_ty->read_all () );
		
		$this->view->display ( "admin_type" );
	
	}
	
	//权限设置
	public function power() {
	
	}
	
	//查看个人
	public function user($id = NULL) {
		if (NULL == $id) {
			$admin = $this->session->userdata ( "admin" );
			$id = $admin ['id'];
		}
		
		$this->view->assign ( "operat", $this->op->read_byid ( $id ) );
		$this->view->assign ( "type", $this->op_ty->read_all () );
		$this->view->display ( "admin_user" );
	}
	
	public function op_write($page = 'admin_operat') {
		$_POST ['time'] = time ();
		$this->op->create ();
		redirect ( $page );
	
	}
	
	public function op_updata($id = NULL, $page = 'admin_operat') {
		$_POST ['time'] = time ();
		
		$this->op->updata_byid ( $id );
		redirect ( $page );
	
	}
	
	public function type_write() {
		$this->op_ty->create ();
		
		echo '<script>history.go(-1);</script>';
	}
}